package com.daguchuangyi.erp_android.util;

import android.content.SharedPreferences;

import com.jude.utils.JUtils;

/**
 * Created by lijianjian on 2018/3/4.
 */

public class PreferenceUtil {

    public static final String TAG_IP_SAVED = "TAG_IP_SAVED";
    public static final String TAG_USER_NAME = "TAG_USER_NAME";
    public static final String TAG_LOGIN_PSW = "TAG_LOGIN_PSW";
    public static final String TAG_SAVE_LOGIN_INFO = "TAG_SAVE_LOGIN_INFO";

    public static void save(String TAG, Object content) {
        SharedPreferences.Editor editor = JUtils.getSharedPreference().edit();
        if (content instanceof String) {
            editor.putString(TAG, (String) content);
        } else if (content instanceof Integer) {
            editor.putInt(TAG, (Integer) content);
        } else if (content instanceof Float) {
            editor.putFloat(TAG, (Float) content);
        } else if (content instanceof Boolean) {
            editor.putBoolean(TAG, (Boolean) content);
        }
        editor.apply();
    }

    public static String getString(String TAG, String defalut) {
        return JUtils.getSharedPreference().getString(TAG, defalut);
    }

    public static boolean getBoolean(String TAG, boolean defalult) {
        return JUtils.getSharedPreference().getBoolean(TAG, defalult);
    }
}
